home *** CD-ROM | disk | FTP | other *** search
- (*************************************************************************
-
- $RCSfile: OLSettings.mod $
- Description: Preferences settings for OL
-
- Created by: fjc (Frank Copeland)
- $Revision: 1.3 $
- $Author: fjc $
- $Date: 1995/01/26 02:07:58 $
-
- Copyright © 1995, Frank Copeland.
- This file is part of OL
- See OL.doc for conditions of use and distribution.
-
- Log entries are at the end of the file.
-
- *************************************************************************)
-
- <* STANDARD- *> <* MAIN- *> <* INITIALISE- *>
-
- MODULE OLSettings;
-
- IMPORT SYS := SYSTEM, d := Dos, du := DosUtil, e := Exec, str := Strings;
-
- (* Preferences settings *)
-
- CONST
-
- StrLen = 128; (* Max length of a string. *)
- OLPF = 04F4C5046H; (* "OLPF" *) (* Tag for preferences file. *)
- PrefsVersion = 1; (* Preferences file version. *)
-
- TYPE
-
- STR = ARRAY StrLen OF CHAR;
-
- CONST
-
- (* Currently supported linkers *)
- ALink* = 0; BLink* = 1; DLink* = 2;
-
- VAR
- SymSearch*, (* Search paths for symbol files. *)
- ObjSearch*, (* Search paths for object files. *)
- WithPath*, (* Directory to write .with files. *)
- ProgPath*, (* Directory to write programs. *)
- SymExt*, (* Extensions for symbol files. *)
- ObjExt*, (* Extensions for object files. *)
- WithExt*, (* Extension for .with files. *)
- LinkCmd*, (* Path of linker. *)
- LinkArgs* (* Command line args for linker. *)
- : STR;
- Verbose*, (* Verbose output. *)
- MakeIcons* (* Create icons for with files and
- ** programs.
- *)
- : BOOLEAN;
- WithFmt* (* Format of .with files. *)
- : LONGINT;
-
- CONST
-
- defSymSearch = "";
- defObjSearch = "";
- defWithPath = "";
- defProgPath = "";
- defSymExt = ".sym";
- defObjExt = ".obj";
- defWithExt = ".with";
- defLinkCmd = "";
- defLinkArgs = "";
- defVerbose = TRUE;
- defMakeIcons = FALSE;
- defWithFmt = BLink;
-
- (*------------------------------------*)
- PROCEDURE Init ();
-
- BEGIN (* Init *)
- SymSearch := defSymSearch;
- ObjSearch := defObjSearch;
- WithPath := defWithPath;
- ProgPath := defProgPath;
- SymExt := defSymExt;
- ObjExt := defObjExt;
- WithExt := defWithExt;
- LinkCmd := defLinkCmd;
- LinkArgs := defLinkArgs;
- Verbose := defVerbose;
- MakeIcons := defMakeIcons;
- WithFmt := defWithFmt;
- END Init;
-
- (*------------------------------------*)
- PROCEDURE LoadPrefs* ( fileName : ARRAY OF CHAR ) : BOOLEAN;
-
- VAR
- pf : d.FileHandlePtr;
- s : ARRAY StrLen OF CHAR;
- dir : ARRAY 3 OF e.LSTRPTR;
- tag : LONGINT; i, ver : INTEGER;
- c : CHAR;
-
- PROCEDURE Read ( fh : d.FileHandlePtr; VAR x : SYS.BYTE );
- VAR i : LONGINT;
- BEGIN (* Read *)
- i := d.FGetC (fh); x := CHR (i)
- END Read;
-
- PROCEDURE ReadBytes
- ( fh : d.FileHandlePtr; VAR x : ARRAY OF SYS.BYTE; n : LONGINT );
- VAR i : LONGINT;
- BEGIN (* ReadBytes *)
- i := d.FRead (fh, x, 1, n)
- END ReadBytes;
-
- PROCEDURE ReadString ( fh : d.FileHandlePtr; VAR x : ARRAY OF CHAR );
- VAR ch : CHAR; i : INTEGER;
- BEGIN (* ReadString *)
- i := 0;
- REPEAT
- Read (fh, ch); x [i] := ch; INC (i)
- UNTIL ch = 0X
- END ReadString;
-
- PROCEDURE ReadBool ( fh : d.FileHandlePtr; VAR x : BOOLEAN );
- VAR i : SHORTINT;
- BEGIN (* ReadBool *)
- Read (fh, i); x := (i # 0)
- END ReadBool;
-
- <*$CopyArrays-*>
- BEGIN (* LoadPrefs *)
- dir [0] := SYS.ADR ("PROGDIR:");
- dir [1] := SYS.ADR ("ENV:OL");
- dir [2] := NIL;
- IF du.Search (dir, fileName, s) THEN
- pf := d.Open (s, d.oldFile);
- IF pf # NIL THEN
- ReadBytes (pf, tag, 4);
- IF tag = OLPF THEN
- Read (pf, c); ver := ORD (c);
- IF ver >= 1 THEN
- ReadString (pf, SymSearch);
- ReadString (pf, ObjSearch);
- ReadString (pf, WithPath);
- ReadString (pf, ProgPath);
- ReadString (pf, SymExt);
- ReadString (pf, ObjExt);
- ReadString (pf, WithExt);
- ReadString (pf, LinkCmd);
- ReadString (pf, LinkArgs);
- ReadBool (pf, Verbose);
- ReadBool (pf, MakeIcons);
- Read (pf, c); WithFmt := ORD (c);
-
- d.OldClose (pf);
- RETURN TRUE
- ELSE
- d.OldClose (pf);
- RETURN FALSE
- END;
- ELSE
- d.OldClose (pf);
- RETURN FALSE
- END;
- ELSE
- RETURN FALSE
- END;
- ELSE
- RETURN FALSE
- END;
- END LoadPrefs;
-
- (*------------------------------------*)
- PROCEDURE SavePrefs* ( fileName : ARRAY OF CHAR ) : BOOLEAN;
-
- VAR pf : d.FileHandlePtr; tag : LONGINT; i : INTEGER; ver : CHAR;
-
- PROCEDURE Write ( fh : d.FileHandlePtr; x : SYS.BYTE );
- VAR i : LONGINT;
- BEGIN (* Write *)
- i := d.FPutC (fh, ORD (x))
- END Write;
-
- PROCEDURE WriteBytes
- ( fh : d.FileHandlePtr; VAR x : ARRAY OF SYS.BYTE; n : LONGINT );
- VAR i : LONGINT;
- BEGIN (* WriteBytes *)
- i := d.FWrite (fh, x, 1, n)
- END WriteBytes;
-
- PROCEDURE WriteString ( fh : d.FileHandlePtr; x : ARRAY OF CHAR );
- <*$CopyArrays-*>
- BEGIN (* WriteString *)
- WriteBytes (fh, x, str.Length (x)); Write (fh, 0X)
- END WriteString;
-
- PROCEDURE WriteBool ( fh : d.FileHandlePtr; x : BOOLEAN );
- VAR i : SHORTINT;
- BEGIN (* WriteBool *)
- IF x THEN i := 1 ELSE i := 0 END; Write (fh, i)
- END WriteBool;
-
- <*$CopyArrays-*>
- BEGIN (* SavePrefs *)
- pf := d.Open (fileName, d.newFile);
- IF pf # NIL THEN
- tag := OLPF; WriteBytes (pf, tag, 4);
- Write (pf, CHR (PrefsVersion));
-
- WriteString (pf, SymSearch);
- WriteString (pf, ObjSearch);
- WriteString (pf, WithPath);
- WriteString (pf, ProgPath);
- WriteString (pf, SymExt);
- WriteString (pf, ObjExt);
- WriteString (pf, WithExt);
- WriteString (pf, LinkCmd);
- WriteString (pf, LinkArgs);
- WriteBool (pf, Verbose);
- WriteBool (pf, MakeIcons);
- Write (pf, CHR (WithFmt));
-
- d.OldClose (pf);
- RETURN TRUE
- ELSE
- RETURN FALSE
- END
- END SavePrefs;
-
- BEGIN (* OLSettings *)
- Init()
- END OLSettings.
-
- (*************************************************************************
-
- $Log: OLSettings.mod $
- # Revision 1.3 1995/01/26 02:07:58 fjc
- # - Release 1.5
- #
- # Revision 1.2 1995/01/09 14:46:16 fjc
- # - Removed icon names, Scan and Link from preferences file
- # format.
- #
- # Revision 1.1 1995/01/06 16:31:16 fjc
- # Initial revision
- #
- *************************************************************************)
-
-